<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加试题 - 试题库管理系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#36CBCB',
                        accent: '#FF7D00',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .scrollbar-hide {
                -ms-overflow-style: none;
                scrollbar-width: none;
            }
            .scrollbar-hide::-webkit-scrollbar {
                display: none;
            }
            .question-card-hover {
                @apply transition-all duration-300 hover:shadow-md hover:border-primary/30;
            }
            .fade-in {
                animation: fadeIn 0.5s ease-in-out;
            }
            @keyframes fadeIn {
                from { opacity: 0; transform: translateY(10px); }
                to { opacity: 1; transform: translateY(0); }
            }
            .scale-in {
                animation: scaleIn 0.3s ease-out forwards;
            }
            @keyframes scaleIn {
                from { transform: scale(0.95); opacity: 0; }
                to { transform: scale(1); opacity: 1; }
            }
            .scale-out {
                animation: scaleOut 0.3s ease-in forwards;
            }
            @keyframes scaleOut {
                from { transform: scale(1); opacity: 1; }
                to { transform: scale(0.95); opacity: 0; }
            }
        }
    </style>
</head>
<body class="bg-gray-50 font-inter text-gray-800 min-h-screen flex flex-col">
    <!-- 顶部导航栏 -->
    <header class="bg-white shadow-sm sticky top-0 z-50 transition-all duration-300">
        <div class="container mx-auto px-4 py-3 flex items-center justify-between">
            <div class="flex items-center space-x-2">
                <button id="sidebar-toggle" class="lg:hidden text-gray-500 hover:text-primary transition-colors">
                    <i class="fa fa-bars text-xl"></i>
                </button>
                <h1 class="text-xl font-bold text-primary flex items-center">
                    <i class="fa fa-book mr-2"></i>
                    <span>试题库管理系统</span>
                </h1>
            </div>
            
            <div class="hidden md:flex items-center space-x-6">
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">首页</a>
                <a href="#" class="text-primary font-medium border-b-2 border-primary pb-1">题库</a>
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">教材版本</a>
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">统计分析</a>
                <a href="#" class="text-gray-600 hover:text-primary transition-colors">系统设置</a>
            </div>
            
            <div class="flex items-center space-x-4">
                <div class="relative">
                    <input type="text" placeholder="搜索试题、知识点..." 
                           class="pl-10 pr-4 py-2 rounded-full bg-gray-100 focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all w-40 lg:w-64">
                    <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                </div>
                
                <div class="relative">
                    <button class="text-gray-500 hover:text-primary transition-colors">
                        <i class="fa fa-bell text-xl"></i>
                        <span class="absolute -top-1 -right-1 bg-danger text-white text-xs rounded-full h-4 w-4 flex items-center justify-center">3</span>
                    </button>
                </div>
                
                <div class="flex items-center space-x-2 cursor-pointer group">
                    <img src="https://picsum.photos/id/64/40/40" alt="用户头像" class="w-8 h-8 rounded-full object-cover border-2 border-transparent group-hover:border-primary transition-all">
                    <span class="hidden md:inline font-medium">张老师</span>
                    <i class="fa fa-angle-down text-gray-400 group-hover:text-primary transition-colors"></i>
                </div>
            </div>
        </div>
    </header>

    <div class="flex flex-1 overflow-hidden">
        <!-- 左侧边栏 - 知识点导航 -->
        <aside id="sidebar" class="w-64 bg-white shadow-md transform -translate-x-full lg:translate-x-0 fixed lg:static h-full z-40 transition-transform duration-300 ease-in-out overflow-y-auto scrollbar-hide">
            <div class="p-4 border-b">
                <div class="flex items-center justify-between mb-3">
                    <h2 class="font-bold text-lg">知识点导航</h2>
                    <div class="relative">
                        <select class="appearance-none bg-gray-100 rounded-lg px-3 py-1 pr-8 focus:outline-none focus:ring-1 focus:ring-primary">
                            <option>全部学科</option>
                            <option selected>数学</option>
                            <option>物理</option>
                            <option>化学</option>
                            <option>生物</option>
                        </select>
                        <i class="fa fa-chevron-down absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 pointer-events-none"></i>
                    </div>
                </div>
                
                <div class="relative">
                    <input type="text" placeholder="搜索知识点..." 
                           class="w-full pl-8 pr-4 py-2 rounded-lg bg-gray-100 focus:outline-none focus:ring-1 focus:ring-primary">
                    <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                </div>
            </div>
            
            <!-- 教材版本选择 -->
            <div class="p-4 border-b">
                <h3 class="font-medium text-sm text-gray-500 mb-2">选择教材版本</h3>
                <div class="space-y-2">
                    <div class="relative">
                        <select class="w-full appearance-none bg-gray-100 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-1 focus:ring-primary">
                            <option selected>人教版 2023版</option>
                            <option>苏教版 2022版</option>
                            <option>北师大版 2023版</option>
                            <option>沪科版 2024版</option>
                        </select>
                        <i class="fa fa-chevron-down absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 pointer-events-none"></i>
                    </div>
                </div>
            </div>
            
            <!-- 知识点树形导航 -->
            <div class="p-4">
                <div class="flex items-center justify-between mb-3">
                    <h3 class="font-medium text-sm text-gray-500">知识点结构</h3>
                    <div class="flex space-x-1">
                        <button id="expand-all" class="text-xs text-gray-500 hover:text-primary">展开</button>
                        <span class="text-gray-300">|</span>
                        <button id="collapse-all" class="text-xs text-gray-500 hover:text-primary">收起</button>
                    </div>
                </div>
                
                <div class="space-y-1">
                    <!-- 章节1 -->
                    <div class="chapter-item">
                        <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                            <div class="flex items-center">
                                <i class="fa fa-book text-primary mr-2"></i>
                                <span class="font-medium">第一章 集合与常用逻辑用语</span>
                            </div>
                            <i class="fa fa-angle-down text-gray-400 transition-transform"></i>
                        </div>
                        
                        <div class="pl-6 mt-1 space-y-1">
                            <div class="section-item">
                                <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                                    <div class="flex items-center">
                                        <i class="fa fa-bookmark-o text-secondary mr-2"></i>
                                        <span>1.1 集合的含义与表示</span>
                                    </div>
                                    <span class="text-xs bg-blue-100 text-blue-600 px-2 py-0.5 rounded-full">32题</span>
                                </div>
                                
                                <div class="pl-6 mt-1 space-y-1">
                                    <div class="knowledge-item bg-primary/5 border-l-2 border-primary p-2 rounded-r-lg cursor-pointer hover:bg-primary/10 transition-colors">
                                        <div class="flex items-center justify-between">
                                            <div class="flex items-center">
                                                <i class="fa fa-dot-circle-o text-primary mr-2"></i>
                                                <span>集合的定义</span>
                                            </div>
                                            <span class="text-xs text-gray-500">3题</span>
                                        </div>
                                    </div>
                                    
                                    <div class="knowledge-item hover:bg-gray-50 p-2 rounded-lg cursor-pointer transition-colors">
                                        <div class="flex items-center justify-between">
                                            <div class="flex items-center">
                                                <i class="fa fa-dot-circle-o text-gray-400 mr-2"></i>
                                                <span>集合的表示方法</span>
                                            </div>
                                            <span class="text-xs text-gray-500">5题</span>
                                        </div>
                                    </div>
                                    
                                    <div class="knowledge-item hover:bg-gray-50 p-2 rounded-lg cursor-pointer transition-colors">
                                        <div class="flex items-center justify-between">
                                            <div class="flex items-center">
                                                <i class="fa fa-dot-circle-o text-gray-400 mr-2"></i>
                                                <span>元素与集合的关系</span>
                                            </div>
                                            <span class="text-xs text-gray-500">4题</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="section-item">
                                <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                                    <div class="flex items-center">
                                        <i class="fa fa-bookmark-o text-secondary mr-2"></i>
                                        <span>1.2 集合间的基本关系</span>
                                    </div>
                                    <span class="text-xs bg-blue-100 text-blue-600 px-2 py-0.5 rounded-full">24题</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 章节2 -->
                    <div class="chapter-item">
                        <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                            <div class="flex items-center">
                                <i class="fa fa-book text-primary mr-2"></i>
                                <span>第二章 一元二次函数、方程和不等式</span>
                            </div>
                            <i class="fa fa-angle-right text-gray-400 transition-transform"></i>
                        </div>
                    </div>
                    
                    <!-- 章节3 -->
                    <div class="chapter-item">
                        <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                            <div class="flex items-center">
                                <i class="fa fa-book text-primary mr-2"></i>
                                <span>第三章 函数概念与性质</span>
                            </div>
                            <i class="fa fa-angle-right text-gray-400 transition-transform"></i>
                        </div>
                    </div>
                    
                    <!-- 章节4 -->
                    <div class="chapter-item">
                        <div class="flex items-center justify-between cursor-pointer hover:bg-gray-50 rounded-lg p-2 transition-colors">
                            <div class="flex items-center">
                                <i class="fa fa-book text-primary mr-2"></i>
                                <span>第四章 指数函数与对数函数</span>
                            </div>
                            <i class="fa fa-angle-right text-gray-400 transition-transform"></i>
                        </div>
                    </div>
                </div>
            </div>
        </aside>
        
        <!-- 主内容区 -->
        <main class="flex-1 overflow-y-auto bg-gray-50 p-4 lg:p-6">
            <div class="container mx-auto">
                <!-- 面包屑导航 -->
                <div class="flex items-center text-sm text-gray-500 mb-4">
                    <a href="#" class="hover:text-primary">首页</a>
                    <i class="fa fa-angle-right mx-2 text-gray-300"></i>
                    <a href="#" class="hover:text-primary">题库</a>
                    <i class="fa fa-angle-right mx-2 text-gray-300"></i>
                    <a href="#" class="hover:text-primary">数学题库</a>
                    <i class="fa fa-angle-right mx-2 text-gray-300"></i>
                    <a href="#" class="hover:text-primary">集合的定义</a>
                    <i class="fa fa-angle-right mx-2 text-gray-300"></i>
                    <span class="text-primary font-medium">添加试题</span>
                </div>
                
                <!-- 内容标题区 -->
                <div class="flex flex-col md:flex-row md:items-center justify-between mb-6">
                    <div>
                        <h2 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-gray-800">添加试题</h2>
                        <p class="text-gray-500 mt-1">请填写以下信息创建新试题</p>
                    </div>
                    
                    <div class="flex space-x-3 mt-4 md:mt-0">
                        <button id="cancel-btn" class="bg-white border border-gray-300 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-50 transition-colors flex items-center">
                            <i class="fa fa-times mr-2"></i> 取消
                        </button>
                        <button id="save-question-btn" class="bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-colors flex items-center">
                            <i class="fa fa-save mr-2"></i> 保存试题
                        </button>
                    </div>
                </div>
                
                <!-- 试题表单 -->
                <div class="bg-white rounded-xl shadow-sm p-6 mb-6 fade-in">
                    <form id="question-form">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">学科</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary">
                                    <option>数学</option>
                                    <option>物理</option>
                                    <option>化学</option>
                                    <option>生物</option>
                                    <option>语文</option>
                                    <option>英语</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">教材版本</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary">
                                    <option>人教版 2023版</option>
                                    <option>苏教版 2022版</option>
                                    <option>北师大版 2023版</option>
                                    <option>沪科版 2024版</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">章节</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary">
                                    <option>第一章 集合与常用逻辑用语</option>
                                    <option>第二章 一元二次函数、方程和不等式</option>
                                    <option>第三章 函数概念与性质</option>
                                    <option>第四章 指数函数与对数函数</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">知识点</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary">
                                    <option>集合的定义</option>
                                    <option>集合的表示方法</option>
                                    <option>元素与集合的关系</option>
                                    <option>集合间的基本关系</option>
                                    <option>集合的运算</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">题型</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary" id="question-type">
                                    <option value="single">单选题</option>
                                    <option value="multiple">多选题</option>
                                    <option value="judge">判断题</option>
                                    <option value="fill">填空题</option>
                                    <option value="answer">解答题</option>
                                    <option value="proof">证明题</option>
                                </select>
                            </div>
                            
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">难度</label>
                                <select class="w-full appearance-none bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary">
                                    <option>简单</option>
                                    <option>中等</option>
                                    <option>困难</option>
                                </select>
                            </div>
                        </div>
                        
                        <div class="mb-6">
                            <label class="block text-sm font-medium text-gray-700 mb-1">题干</label>
                            <div class="relative">
                                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                    <button class="text-gray-400 hover:text-gray-600">
                                        <i class="fa fa-bold"></i>
                                    </button>
                                    <button class="text-gray-400 hover:text-gray-600 ml-2">
                                        <i class="fa fa-italic"></i>
                                    </button>
                                    <button class="text-gray-400 hover:text-gray-600 ml-2">
                                        <i class="fa fa-underline"></i>
                                    </button>
                                    <button class="text-gray-400 hover:text-gray-600 ml-2">
                                        <i class="fa fa-link"></i>
                                    </button>
                                    <button class="text-gray-400 hover:text-gray-600 ml-2">
                                        <i class="fa fa-image"></i>
                                    </button>
                                    <button class="text-gray-400 hover:text-gray-600 ml-2">
                                        <i class="fa fa-code"></i>
                                    </button>
                                </div>
                                
                </div>
                
                <!-- 试题内容编辑器 -->
                <div class="mb-6">
                    <div class="flex items-center justify-between mb-2">
                        <label class="block text-sm font-medium text-gray-700">题干内容</label>
                        <div class="text-xs text-gray-500">
                            <span id="question-length">0</span>/500 字符
                        </div>
                    </div>
                    <div class="border border-gray-200 rounded-lg overflow-hidden">
                        <div class="p-3 bg-gray-50 border-b border-gray-200 flex items-center space-x-3">
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-bold"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-italic"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-underline"></i>
                            </button>
                            <span class="h-4 w-px bg-gray-300"></span>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-list-ul"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-list-ol"></i>
                            </button>
                            <span class="h-4 w-px bg-gray-300"></span>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-link"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-image"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-table"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-code"></i>
                            </button>
                            <span class="h-4 w-px bg-gray-300"></span>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-subscript"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-superscript"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-square-root"></i>
                            </button>
                            <button class="text-gray-500 hover:text-gray-700 p-1 rounded hover:bg-gray-200 transition-colors">
                                <i class="fa fa-fraction"></i>
                            </button>
                        </div>
                        <div class="p-4">
                            <div contenteditable="true" class="min-h-[100px] focus:outline-none" id="question-content"></div>
                        </div>
                    </div>
                </div>
                
                <!-- 选项区域 - 根据题型动态显示 -->
                <div id="options-container" class="mb-6">
                    <h3 class="text-sm font-medium text-gray-700 mb-3">选项</h3>
                    
                    <div class="space-y-3">
                        <div class="option-item flex items-start space-x-3">
                            <div class="mt-1">
                                <input type="radio" name="option" value="A" checked class="w-4 h-4 text-primary focus:ring-primary">
                            </div>
                            <div class="flex-1">
                                <div class="border border-gray-200 rounded-lg overflow-hidden">
                                    <div class="p-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between">
                                        <span class="text-xs font-medium text-gray-500">选项 A</span>
                                        <button class="text-gray-400 hover:text-red-500 text-sm">
                                            <i class="fa fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="p-3">
                                        <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="option-item flex items-start space-x-3">
                            <div class="mt-1">
                                <input type="radio" name="option" value="B" class="w-4 h-4 text-primary focus:ring-primary">
                            </div>
                            <div class="flex-1">
                                <div class="border border-gray-200 rounded-lg overflow-hidden">
                                    <div class="p-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between">
                                        <span class="text-xs font-medium text-gray-500">选项 B</span>
                                        <button class="text-gray-400 hover:text-red-500 text-sm">
                                            <i class="fa fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="p-3">
                                        <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="option-item flex items-start space-x-3">
                            <div class="mt-1">
                                <input type="radio" name="option" value="C" class="w-4 h-4 text-primary focus:ring-primary">
                            </div>
                            <div class="flex-1">
                                <div class="border border-gray-200 rounded-lg overflow-hidden">
                                    <div class="p-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between">
                                        <span class="text-xs font-medium text-gray-500">选项 C</span>
                                        <button class="text-gray-400 hover:text-red-500 text-sm">
                                            <i class="fa fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="p-3">
                                        <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="option-item flex items-start space-x-3">
                            <div class="mt-1">
                                <input type="radio" name="option" value="D" class="w-4 h-4 text-primary focus:ring-primary">
                            </div>
                            <div class="flex-1">
                                <div class="border border-gray-200 rounded-lg overflow-hidden">
                                    <div class="p-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between">
                                        <span class="text-xs font-medium text-gray-500">选项 D</span>
                                        <button class="text-gray-400 hover:text-red-500 text-sm">
                                            <i class="fa fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="p-3">
                                        <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <button id="add-option-btn" class="mt-3 flex items-center text-primary hover:text-primary/80 text-sm">
                        <i class="fa fa-plus-circle mr-1"></i> 添加选项
                    </button>
                </div>
                
                <!-- 答案解析区域 -->
                <div class="mb-6">
                    <h3 class="text-sm font-medium text-gray-700 mb-3">答案解析</h3>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1">正确答案</label>
                            <div class="border border-gray-200 rounded-lg overflow-hidden">
                                <div class="p-3">
                                    <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none" id="correct-answer"></div>
                                </div>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1">答案解析</label>
                            <div class="border border-gray-200 rounded-lg overflow-hidden">
                                <div class="p-3">
                                    <div contenteditable="true" class="min-h-[100px] text-sm focus:outline-none" id="answer-explanation"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 标签与备注区域 -->
                <div class="mb-6">
                    <h3 class="text-sm font-medium text-gray-700 mb-3">标签与备注</h3>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1">添加标签</label>
                            <div class="flex flex-wrap gap-2 p-3 border border-gray-200 rounded-lg">
                                <div class="flex items-center bg-primary/10 text-primary text-xs px-2 py-1 rounded">
                                    集合
                                    <button class="ml-1 text-primary/70 hover:text-primary"><i class="fa fa-times-circle"></i></button>
                                </div>
                                <div class="flex items-center bg-primary/10 text-primary text-xs px-2 py-1 rounded">
                                    基础概念
                                    <button class="ml-1 text-primary/70 hover:text-primary"><i class="fa fa-times-circle"></i></button>
                                </div>
                                <div class="relative">
                                    <input type="text" placeholder="添加标签..." class="text-sm border-none focus:ring-0 focus:outline-none w-24 lg:w-32">
                                    <button class="absolute right-0 top-1/2 transform -translate-y-1/2 text-primary hover:text-primary/80">
                                        <i class="fa fa-plus-circle"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1">备注（可选）</label>
                            <div class="border border-gray-200 rounded-lg overflow-hidden">
                                <div class="p-3">
                                    <textarea rows="2" placeholder="输入备注信息..." class="w-full border-none focus:ring-0 focus:outline-none text-sm"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 附件上传区域 -->
                <div class="mb-6">
                    <h3 class="text-sm font-medium text-gray-700 mb-3">附件上传</h3>
                    
                    <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-primary transition-colors">
                        <div class="flex flex-col items-center">
                            <i class="fa fa-cloud-upload text-4xl text-gray-400 mb-3"></i>
                            <p class="text-sm text-gray-500 mb-1">拖放文件到此处，或</p>
                            <button class="bg-white border border-gray-300 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-50 transition-colors text-sm">
                                选择文件上传
                            </button>
                            <p class="text-xs text-gray-400 mt-3">支持 JPG, PNG, PDF, Word 格式，最大 10MB</p>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        
        <!-- 底部操作栏 -->
        <div class="bg-white rounded-xl shadow-sm p-4 flex justify-end space-x-3">
            <button id="cancel-btn" class="bg-white border border-gray-300 text-gray-700 px-5 py-2 rounded-lg hover:bg-gray-50 transition-colors flex items-center">
                <i class="fa fa-times mr-2"></i> 取消
            </button>
            <button id="save-draft-btn" class="bg-gray-100 text-gray-700 px-5 py-2 rounded-lg hover:bg-gray-200 transition-colors flex items-center">
                <i class="fa fa-save mr-2"></i> 保存草稿
            </button>
            <button id="preview-btn" class="bg-white border border-primary text-primary px-5 py-2 rounded-lg hover:bg-primary/5 transition-colors flex items-center">
                <i class="fa fa-eye mr-2"></i> 预览
            </button>
            <button id="save-question-btn" class="bg-primary text-white px-5 py-2 rounded-lg hover:bg-primary/90 transition-colors flex items-center">
                <i class="fa fa-check mr-2"></i> 保存并添加下一题
            </button>
        </div>
    </div>
</div>

<script>
    // 侧边栏切换
    document.getElementById('sidebar-toggle').addEventListener('click', function() {
        const sidebar = document.getElementById('sidebar');
        sidebar.classList.toggle('-translate-x-full');
    });
    
    // 章节折叠/展开功能
    document.querySelectorAll('.chapter-item').forEach(chapter => {
        const header = chapter.querySelector(':scope > div');
        const content = chapter.querySelector(':scope > div + div');
        const icon = header.querySelector('.fa');
        
        if (content) {
            header.addEventListener('click', () => {
                content.classList.toggle('hidden');
                icon.classList.toggle('fa-angle-right');
                icon.classList.toggle('fa-angle-down');
            });
        }
    });
    
    // 展开/收起所有章节
    document.getElementById('expand-all').addEventListener('click', function() {
        document.querySelectorAll('.chapter-item').forEach(chapter => {
            const content = chapter.querySelector(':scope > div + div');
            const icon = chapter.querySelector('.fa');
            
            if (content && content.classList.contains('hidden')) {
                content.classList.remove('hidden');
                icon.classList.remove('fa-angle-right');
                icon.classList.add('fa-angle-down');
            }
        });
    });
    
    document.getElementById('collapse-all').addEventListener('click', function() {
        document.querySelectorAll('.chapter-item').forEach(chapter => {
            const content = chapter.querySelector(':scope > div + div');
            const icon = chapter.querySelector('.fa');
            
            if (content && !content.classList.contains('hidden')) {
                content.classList.add('hidden');
                icon.classList.remove('fa-angle-down');
                icon.classList.add('fa-angle-right');
            }
        });
    });
    
    // 题型切换功能
    document.getElementById('question-type').addEventListener('change', function() {
        const type = this.value;
        const optionsContainer = document.getElementById('options-container');
        
        // 根据题型显示/隐藏选项区域
        if (type === 'single' || type === 'multiple' || type === 'judge') {
            optionsContainer.classList.remove('hidden');
        } else {
            optionsContainer.classList.add('hidden');
        }
        
        // 根据题型调整选项内容
        if (type === 'judge') {
            // 判断题只显示A(对)和B(错)两个选项
            const optionItems = document.querySelectorAll('.option-item');
            optionItems.forEach((item, index) => {
                if (index < 2) {
                    item.classList.remove('hidden');
                    const optionLabel = item.querySelector('.text-xs.font-medium');
                    optionLabel.textContent = index === 0 ? '选项 A (对)' : '选项 B (错)';
                } else {
                    item.classList.add('hidden');
                }
            });
            
            // 隐藏添加选项按钮
            document.getElementById('add-option-btn').classList.add('hidden');
        } else if (type === 'single' || type === 'multiple') {
            // 单选题和多选题显示所有选项
            const optionItems = document.querySelectorAll('.option-item');
            optionItems.forEach((item, index) => {
                item.classList.remove('hidden');
                const optionLabel = item.querySelector('.text-xs.font-medium');
                optionLabel.textContent = `选项 ${String.fromCharCode(65 + index)}`;
            });
            
            // 显示添加选项按钮
            document.getElementById('add-option-btn').classList.remove('hidden');
        }
    });
    
    // 添加选项按钮
    document.getElementById('add-option-btn').addEventListener('click', function() {
        const optionsContainer = document.querySelector('#options-container .space-y-3');
        const optionCount = optionsContainer.querySelectorAll('.option-item').length;
        const newOptionLetter = String.fromCharCode(65 + optionCount);
        
        const newOption = document.createElement('div');
        newOption.className = 'option-item flex items-start space-x-3 scale-in';
        newOption.innerHTML = `
            <div class="mt-1">
                <input type="radio" name="option" value="${newOptionLetter}" class="w-4 h-4 text-primary focus:ring-primary">
            </div>
            <div class="flex-1">
                <div class="border border-gray-200 rounded-lg overflow-hidden">
                    <div class="p-2 bg-gray-50 border-b border-gray-200 flex items-center justify-between">
                        <span class="text-xs font-medium text-gray-500">选项 ${newOptionLetter}</span>
                        <button class="text-gray-400 hover:text-red-500 text-sm delete-option">
                            <i class="fa fa-times"></i>
                        </button>
                    </div>
                    <div class="p-3">
                        <div contenteditable="true" class="min-h-[50px] text-sm focus:outline-none"></div>
                    </div>
                </div>
            </div>
        `;
        
        optionsContainer.appendChild(newOption);
        
        // 为新添加的选项绑定删除事件
        newOption.querySelector('.delete-option').addEventListener('click', function() {
            newOption.classList.add('scale-out');
            setTimeout(() => {
                newOption.remove();
                updateOptionLabels();
            }, 300);
        });
        
        // 更新选项的类型（单选/多选）
        updateOptionTypes();
    });
    
    // 删除选项
    document.querySelectorAll('.delete-option').forEach(button => {
        button.addEventListener('click', function() {
            const optionItem = this.closest('.option-item');
            optionItem.classList.add('scale-out');
            setTimeout(() => {
                optionItem.remove();
                updateOptionLabels();
            }, 300);
        });
    });
    
    // 更新选项标签（A、B、C等）
    function updateOptionLabels() {
        const optionItems = document.querySelectorAll('.option-item');
        optionItems.forEach((item, index) => {
            const optionLetter = String.fromCharCode(65 + index);
            const optionLabel = item.querySelector('.text-xs.font-medium');
            optionLabel.textContent = `选项 ${optionLetter}`;
            item.querySelector('input').value = optionLetter;
        });
    }
    
    // 更新选项类型（单选/多选）
    function updateOptionTypes() {
        const questionType = document.getElementById('question-type').value;
        const inputs = document.querySelectorAll('.option-item input');
        
        inputs.forEach(input => {
            input.type = questionType === 'multiple' ? 'checkbox' : 'radio';
        });
    }
    
    // 监听题型变化，更新选项类型
    document.getElementById('question-type').addEventListener('change', updateOptionTypes);
    
    // 题干字数统计
    const questionContent = document.getElementById('question-content');
    const questionLength = document.getElementById('question-length');
    
    questionContent.addEventListener('input', function() {
        const length = this.textContent.length;
        questionLength.textContent = length;
        
        if (length > 500) {
            questionLength.classList.add('text-red-500');
        } else {
            questionLength.classList.remove('text-red-500');
        }
    });
    
    // 保存试题按钮
    document.getElementById('save-question-btn').addEventListener('click', function() {
        // 显示加载状态
        this.innerHTML = '<i class="fa fa-spinner fa-spin mr-2"></i> 保存中...';
        this.disabled = true;
        
        // 模拟保存操作
        setTimeout(() => {
            // 显示成功提示
            this.innerHTML = '<i class="fa fa-check mr-2"></i> 保存成功';
            this.classList.remove('bg-primary');
            this.classList.add('bg-success');
            
            // 3秒后恢复原状
            setTimeout(() => {
                this.innerHTML = '<i class="fa fa-check mr-2"></i> 保存并添加下一题';
                this.classList.remove('bg-success');
                this.classList.add('bg-primary');
                this.disabled = false;
            }, 3000);
        }, 1500);
    });
    
    // 取消按钮
    document.getElementById('cancel-btn').addEventListener('click', function() {
        if (confirm('确定要取消吗？未保存的内容将丢失。')) {
            window.history.back();
        }
    });
</script>
</body>
</html>